<!--
 * @页面名称:
 * @描述:
 * @作者: 辛慰
 * @Date: 2019-06-03 17:44:55
 -->
<template>
  <div class="con-item">
    <div class="time-line">
      <div class="time-query">
        <el-select @change="selectTIime" v-model="form.region">
          <el-option
            v-for="item in dateList"
            :key="item.id"
            :label="item.date"
            :value="item.id"
          ></el-option>
        </el-select>
      </div>
      <!-- <imageSnapTimeline :snapImages="snapImages" :ops="ops" /> -->
      <!-- <div class="vuescroll-box"> -->
      <vuescroll :ops="ops">
          <div class="timeline-box">
              <div class="timeline-item" v-for="(item, index) in equipStatusInfo" :key="index">
                  <div class="warning-icon" ref="scaleImg" v-if="item.state == 1" @mousemove="scalein(index, item.state)" @mouseout="scaleout(index, item.state)"></div>
                  <div class="success-icon" ref="scaleImg" v-if="item.state == 0" @mousemove="scalein(index, item.state)" @mouseout="scaleout(index, item.state)"></div>
                  <div class="line" :style="{visibility:index == (equipStatusInfo.length - 1) ? 'hidden': 'visible'}"></div>
                  <p class="date-text">{{ item.recondingTime }}</p>
                  <p class="operator" v-if="item.state == 0">正常</p>
                  <p class="operator" v-if="item.state == 1">异常</p>
              </div>
          </div>
      </vuescroll>
      <!-- </div> -->
    </div>
    <el-table :data="equipmentInfo" border style="width: 100%;margin-bottom:55px;margin-top:80px;">
      <el-table-column  prop="equipmentName"  label="设备名称" align="center"></el-table-column>
      <el-table-column  prop="recondingTime" label="记录时间" align="center"></el-table-column>
      <el-table-column  prop="equipmentState"  label="设备状态" align="center"></el-table-column>
      <el-table-column  prop="localtion"  label="位置" align="center"></el-table-column>
    </el-table>
    <div class="pagin">
      <span class="total">共{{totalCount}}条数据</span>
      <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage"
      layout="sizes, prev, pager, next"
      :page-sizes="[2, 5, 10, 20]"
      :total="totalCount">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import vuescroll from 'vuescroll'
import imageSnapTimeline from '@/components/imageSnapTimeline'
export default {
  data () {
    return {
      equipmentInfo: [],
      equipmentInfo0: [
        {
          equipmentName: '空调',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0 // 状态 0--正常  1---异常
        }, {
          equipmentName: '灯',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }, {
          equipmentName: '门',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }
      ],
      equipmentInfo1: [
        {
          equipmentName: '空调',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0 // 状态 0--正常  1---异常
        }, {
          equipmentName: '灯',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }, {
          equipmentName: '门',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }, {
          equipmentName: '空调',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0 // 状态 0--正常  1---异常
        }, {
          equipmentName: '灯',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }, {
          equipmentName: '门',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '正常',
          localtion: '001室',
          state: 0
        }, {
          equipmentName: '窗帘',
          recondingTime: '2019-05-21 10:08:56',
          equipmentState: '异常',
          localtion: '001室',
          state: 1
        }
      ],
      currImage: '',
      dialogTableVisible: false, // 模态框显示状态
      currentPage: 1, // 当前页
      pagesize: 10, // 一页的数量
      totalCount: 10, // 总条数
      form: {
        region: '近一天'
      },
      dateList: [
        {
          id: 0,
          date: '近一天'
        },
        {
          id: 1,
          date: '近七天'
        }
      ],
      equipStatusInfo: [],
      ops: { // 滚动条参数配置
        bar: {
          showDelay: 500,
          onlyShowBarOnScroll: true,
          keepShow: true,
          background: '#DEDEDE',
          opacity: 1,
          hoverStyle: false,
          specifyBorderRadius: false,
          minSize: false,
          size: '6px',
          disable: false
        },
        scrollPanel: {
          scrollingX: true,
          scrollingY: false
        }
      }
    }
  },
  components: {
    vuescroll,
    imageSnapTimeline
  },
  mounted () {
    this.equipmentInfo = this.equipmentInfo0
    this.equipStatusInfo = this.equipmentInfo0
    this.totalCount = this.equipmentInfo.length
  },
  methods: {
    selectTIime (n) {
      if (n === 0) {
        this.equipmentInfo = this.equipmentInfo0
        this.equipStatusInfo = this.equipmentInfo0
      } else if (n === 1) {
        this.equipmentInfo = this.equipmentInfo1
        this.equipStatusInfo = this.equipmentInfo1
      }
      this.totalCount = this.equipmentInfo.length
    },
    // 移入事件
    scalein (index, state) {
      if (state === 0) {
        let nel = this.$refs.scaleImg[index]
        nel.classList.add('dynamic-success')
      } else if (state === 1) {
        let nel = this.$refs.scaleImg[index]
        nel.classList.add('dynamic-warning')
      }
    },
    // 移出事件
    scaleout (index, state) {
      if (state === 0) {
        let nel = this.$refs.scaleImg[index]
        nel.classList.remove('dynamic-success')
      } else if (state === 1) {
        let nel = this.$refs.scaleImg[index]
        nel.classList.remove('dynamic-warning')
      }
    },
    checkSubmember (val, index) {
      this.currImage = val.snapIamge
      this.dialogTableVisible = true
    },
    checkDisappear () {
      this.dialogTableVisible = false
    },
    handleSizeChange (val) {
      this.pagesize = val
    },
    handleCurrentChange (val) {
      this.currentPage = val
    }
  }
}
</script>

<style scoped>
.time-line {
  width: 100%;
  height: 2.2rem;
}
.time-query {
  display: flex;
  justify-content: flex-start;
}
.query {
  margin-right: .2rem;
}
.vuescroll-box {
  overflow-x: hidden;
  border: 1px solid #333;
  box-sizing: border-box;
}
.timeline-box {
  margin-top: .2rem;
  height: 1.8rem;
  padding-left: .6rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border: 1px solid #eee;
  box-sizing: border-box;
  cursor: pointer;
}
.timeline-item {
  height: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  position: relative;
}
.camera-img {
  width: .24rem;
  height: .24rem;
  display: inline-block;
}
.warning-icon {
  width: .24rem;
  height: .24rem;
  border-radius: 50%;
  background: red;
}
.success-icon {
  width: .24rem;
  height: .24rem;
  border-radius: 50%;
  background: green;
}
.dynamic-warning {
  animation:warning 1.3s infinite ease-in-out;
}
.dynamic-success {
  animation:success 1.3s infinite ease-in-out;
}
@keyframes warning {
  0% {
    box-shadow: 0 0 .08rem .06rem #fff;
  }
  50% {
    box-shadow: 0 0 .08rem .06rem #ec2020;
  }
  100% {
    box-shadow: 0 0 .08rem .06rem #fff;
  }
}
@keyframes success {
  0% {
    box-shadow: 0 0 .08rem .06rem #fff;
  }
  50% {
    box-shadow: 0 0 .08rem .06rem #0d4f3c;
  }
  100% {
    box-shadow: 0 0 .08rem .06rem #fff;
  }
}
.line {
  width: 1.4rem;
  display: inline-block;
  border-top: 2px solid #333;
}
.date-text {
  font-size: .12rem;
  position: absolute;
  top: 65%;
  left: -.4rem;
}
.operator {
  font-size: .14rem;
  position: absolute;
  top: 24%;
  left: 0px;
}

.snap-small-img {
  width: .6rem;
  height: .6rem;
  display: block;
  position: absolute;
  top: 6%;
  left: -.2rem;
}
.snapImage {
  width: .4rem;
  height: .3rem;
  display: block;
}
.modal{
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.3);
  z-index: 1000;
}
.modalImg{
  width: 6.8rem;
  height: 4.2rem;
  z-index: 1001;
  position: relative;
  top: 1.34rem;
}
.modalIcon{
  width: .5rem;
  height: .5rem;
  position: relative;
  top: 2.2rem;
  left: -3.63rem;
  cursor: pointer;
}
.el-table thead {
  background: #f3f4f8;
}
.pagin {
  display: flex;
  justify-content: space-between;
}
</style>
